import socket
from DesModule import *

TCP_IP = "192.168.1.111"
TCP_PORT = 2024
KEY = "12345678"

tcpserver = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
tcpserver.bind((TCP_IP, TCP_PORT))
tcpserver.listen(5)

while True:
    conn, addr = tcpserver.accept()
    print(conn)
    while True:
        try:
            data = receive_encrypted_data(conn, KEY)
            print(data)
            ret_data = input("请回复：")
            send_encrypted_data(conn, ret_data, KEY)
        except Exception:
            break
    conn.close()